<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script>
	let num1,num2=0,num3=123,str1='',str2='hello',flag=null;
	    console.log(Boolean(num1));  //未定义型转布尔型：false
	    console.log(Boolean(num2));  //数值0转布尔型：false
	    console.log(Boolean(num3));  //非0数值转布尔型：true
	    console.log(Boolean(str1));  //空串转布尔型：false
	    console.log(Boolean(str2));  //非空字符转布尔型：true
	    console.log(Boolean(flag));  //null转布尔型：false
	    //Boolean()函数会将任何非空字符串和非零的数值转换为true
	    //将空字符串、0、NaN、undefined和null转换为false
		console.log('-----------');
		    //未定义转数值
		    console.log(Number(num1)); //
		    console.log(parseInt(num1));  //
		    console.log(parseFloat(num1));  //
		    console.log('---字符转数值---');  //
		    //字符型转数值
		    console.log(Number(str1));   //空串转数值：
		    console.log(parseInt(str1));   //空串转数值：
		    console.log(parseFloat(str1));   //空串转数值：
		    console.log(Number(str2));   //非空串转数值：
		    console.log(parseInt(str2));   //非空串转数值：
		    console.log(parseFloat(str2));  //非空串转数值：
		    let str4='4.34hello';
		    console.log(Number(str4));  //
		    console.log(parseInt(str4));  //
		    console.log(parseFloat(str4));  //
			console.log('-------------');
			    let isNaN;
			    isNaN=Number(str4);
			    console.log(isNaN); //NaN
			    console.log(Boolean(isNaN));  //false
			    console.log('--------');
			    console.log(String(num1));  //undefinde
			    console.log(num3.toString());
			    //console.log(num1.toString());
	</script>
</html>